//
//  ZiXunWebViewTableViewCell.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/5/10.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "ZiXunWebViewTableViewCell.h"

@implementation ZiXunWebViewTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addMySubview];
    }
    return self;
}

// 布局
- (void)addMySubview
{
   
}

- (void)setRequestUrl:(NSString *)requestUrl
{
    self.myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 100 * kAdjustParamater)];
    self.myWebView.delegate = self;
    self.myWebView.backgroundColor = [UIColor whiteColor];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:requestUrl]];
    [self.myWebView loadRequest:request];
    [self.contentView addSubview:_myWebView];
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    CGFloat height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
    CGRect newFrame = webView.frame;
    newFrame.size.height = height;
    webView.frame = newFrame;
}

@end
